<?php 
namespace app\common\model;

use think\Model;
use think\Db;


class Ad extends Model
{
	public function reader($size,$tname,$type)
	{
		if($tname){
			$res = Db::name('advert')
			->where('tname',$tname)
			->order('id asc')
			->paginate($size);
		}else{
			$res = Db::name('advert')
			->where('type',$type)
			->order('id desc')
			->paginate($size);
		}
	    return $res;
	}
	public function getad($id)
	{
	    $res = Db::name('advert')->where('id',$id)->select();
	    return $res;
	}
	public function zt($id,$zt)
	{  
	    
	                $res = db('advert')->where('id',$id)->update(['zt' => $zt]);
	                return $res;
	}
	public function add($shuju)
	{  
	    
	                $res = Db('advert') -> insert($shuju);
	                return $res;
	}
	public function del($id)
	{  
	    // $id=input('id');
	    $res = Db::name('advert')->delete($id);
	    // echo url('picture');
	    return $res;
	}
	public function edit($id,$shuju)
	{  
	    
	                $res = Db('advert') -> where('id', $id)->update($shuju);
	                return $res;
	}
}